package com.wyb.controller;

import com.wyb.constant.Result;
import com.wyb.pojo.User;
import com.wyb.service.RegisterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class RegisterController {
    @Autowired
    private RegisterService registerService;

    @PostMapping("/register")
    public Result register(@RequestBody User user){
        return registerService.register(user)?new Result(200,"注册成功",null):new Result(201,"注册失败",null);
    }
    @GetMapping("/register/name")
    public Result findUserName(@RequestParam String userName){
        return registerService.findUserName(userName)?new Result(200, "用户名合法", null):new Result(201, "用户名已存在请重新输入", null);

    }
}
